<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%@include file="common/main.jsp"%>
<html>
<body>
<br>
<!--通过bootstrap的栅格系统布局-->
<div class="container">
    <!--标题-->
    <div class="row">
        <div class="col-md-12">
            <h1>SSM-CRUD</h1>
        </div>

    </div>

    <!--按钮-->
    <div class="row">
        <div class="col-md-4 col-md-offset-8">
            <a href="${basePath}/person/add.html">  <button class="btn btn-primary">新增</button></a>
            <%--<button class="btn btn-danger">删除</button>--%>
        </div>
    </div>

    <!--显示表格数据-->
    <div class="row">
        <div class="col-md-12">
            <table class="table table-hover">
                <tr>
                    <th>#</th>
                    <th>username</th>
                    <th>account</th>
                    <th>password</th>
                    <th>telephone</th>
                    <th>sex</th>
                    <th>address</th>
                    <th>操作</th>
                </tr>


                <c:forEach items="${pageInfo.list}" var="person">
                    <tr>
                        <th>${person.id}</th>
                        <th>${person.username}</th>
                        <th>${person.account}</th>
                        <th>${person.password}</th>
                        <th>${person.telephone}</th>
                        <th>${person.sex=="1"?"男":"女" }</th>
                        <th>${person.address}</th>
                        <th>
                            <button class="btn btn-primary">
                                <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                                编辑
                            </button>

                            <button class="btn btn-danger">
                                <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
                                删除
                            </button>

                        </th>
                    </tr>
                </c:forEach>

            </table>
        </div>
    </div>
    <!--显示分页信息-->
    <div class="row">
        <!--文字信息-->
        <div class="col-md-6">
            当前第 ${pageInfo.pageNum} 页.总共 ${pageInfo.pages} 页.一共 ${pageInfo.total} 条记录
        </div>

        <!--点击分页-->
        <div class="col-md-6">
            <nav aria-label="Page navigation">
                <ul class="pagination">

                    <li><a href="${basePath}/page?pageNum=1">首页</a></li>

                    <!--上一页-->
                    <c:if test="${pageInfo.hasPreviousPage}">
                    <li>
                    <a href="${basePath}/page?pageNum=${pageInfo.pageNum-1}" aria-label="Previous">
                                <span aria-hidden="true">«</span>
                            </a>
                    </li>
                    </c:if>

                    <!--循环遍历连续显示的页面，若是当前页就高亮显示，并且没有链接-->
                    <c:forEach items="${pageInfo.navigatepageNums}" var="page_num">
                        <c:if test="${page_num == pageInfo.pageNum}">
                            <li class="active"><a href="#">${page_num}</a></li>
                        </c:if>
                        <c:if test="${page_num != pageInfo.pageNum}">
                            <li><a href="${basePath}/page?pageNum=${page_num}">${page_num}</a></li>
                        </c:if>
                    </c:forEach>

                    <!--下一页-->
                    <c:if test="${pageInfo.hasNextPage}">
                    <li>
                    <a href="${basePath}/page?pageNum=${pageInfo.pageNum+1}"
                               aria-label="Next">
                                <span aria-hidden="true">»</span>
                            </a>
                    </li>
                     </c:if>

                    <li><a href="${basePath}/page?pageNum=${pageInfo.pages}">尾页</a></li>
                </ul>
            </nav>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="webjars/jquery/3.2.1/jquery.min.js"></script>
<script>
$("#username").val("123");
</script>
</html>
